//引入第三层的方法
let {
	getClasses,
	addClasses,
	deleteClasses,
	updateClasses,
	// searchClasses,
} = require("../dao/classesDao");
//获取分类
module.exports.getClasses = async function () {
	//等待第三层的数据
	let data = await getClasses();
	return {
		message: "分类数据获取成功",
		code: 1,
		data,
	};
};

//添加分类
module.exports.addClasses = async function (classes) {
	let data = await addClasses(classes);
	return {
		message: "分类添加成功",
		code: 1,
		data,
	};
};
//删除分类
module.exports.deleteClasses = async function (classId) {
	//调用第三层的方法
	let data = await deleteClasses(classId);

	console.log(22222, data);
	return {
		message: "删除成功",
		code: 1,
		data,
	};
};

//修改分类
module.exports.updateClasses = async (params) => {
	const data = await updateClasses(params);
	if (data.nModified > 0) {
		return {
			message: "数据修改成功",
			code: 1,
		};
	} else {
		return {
			message: "数据修改失败",
			code: 0,
		};
	}
};
